package com.xff.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class PageController {


    @RequestMapping("/admin")
    public String admin(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin";
        }
        else
            return "login";

    }
    @RequestMapping("/admin_book")
    public String admin_book(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_book";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_apply")
    public String admin_apply(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_apply";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_loss")
    public String admin_loss(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_loss";
        }
        else
            return "login";
    }

    @RequestMapping("/admin_penalty")
    public String admin_penalty(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_penalty";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_subscribe")
    public String admin_subscribe(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_subscribe";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_booktype")
    public String admin_booktype(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_booktype";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_borrow")
    public String admin_borrow(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_borrow";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_history")
    public String admin_history(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_history";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_user")
    public String admin_user(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_user";
        }
        else
            return "login";
    }
    @RequestMapping("/admin_seat")
    public String admin_seat(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==2) {
            return "admin_seat";
        }
        else
            return "login";
    }

    @RequestMapping("/borrow")
    public String borrow(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==1) {
            return "borrow";
        }
        else
            return "login";
    }
    @RequestMapping("/history")
    public String history(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==1) {
            return "history";
        }
        else
            return "login";
    }

    @RequestMapping("/index")
    public String index(){
        return "index";
    }
    @RequestMapping("/index2")
    public String index2(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==1) {
            return "index2";
        }
        else
            return "login";
    }
    @GetMapping (value = {"/login","/"})
    public String login(){
        return "login";
    }
    @RequestMapping("/register")
    public String register(){
        return "register";
    }
    @RequestMapping("/select")
    public String select(HttpSession session){
        if(session.getAttribute("status")!=null&&(int)session.getAttribute("status")==1) {
            return "select";
        }
        else
            return "login";
    }

}
